home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 2: CDPD 1
/
Almathera Ten on Ten - Disc 2: CDPD 1.iso
/
pd
/
576-600
/
581
/
prism
/
source
/
source.lzh
/
config.c
next >
Wrap
C/C++ Source or Header
|
1991-12-05
|
5KB
|
200 lines
/**********************************************************************
* PRISM Configuration Editor routine ... *
* *
* Written by Syd L. Bolton Copyright (c)1991 *
* Legendary Design Technologies Inc. *
* Freely Redistributable *
\**********************************************************************/
#include "config.h"
#include "mx.c"
configure()
{
struct IntuiMessage *message;
struct Window *ConfigWindow;
struct RastPort *Crp;
ULONG class;
int configexit=0;
ChangeSprite(&WorkScreen->ViewPort,&Cursor,ChipBlank);
maxcolor=(1 << WorkScreen->RastPort.BitMap->Depth)-1;
NewWindowStructure1.BlockPen=maxcolor;
NewWindowStructure1.Screen=WorkScreen;
/*** I know I should have put these in an array .. but I didn't. OH well */
IText1.FrontPen=maxcolor; IText2.FrontPen=maxcolor;
IText3.FrontPen=maxcolor; IText4.FrontPen=maxcolor;
IText5.FrontPen=maxcolor; IText6.FrontPen=maxcolor;
IText7.FrontPen=maxcolor; IText8.FrontPen=maxcolor;
IText9.FrontPen=maxcolor; IText10.FrontPen=maxcolor;
IText11.FrontPen=maxcolor; IText12.FrontPen=maxcolor;
IText13.FrontPen=maxcolor; IText14.FrontPen=maxcolor;
IText15.FrontPen=0; IText15.BackPen=maxcolor-1;
IText16.FrontPen=0; IText16.BackPen=maxcolor-1;
IText17.FrontPen=0; IText17.BackPen=maxcolor-1;
/** Set up current settings **/
sprintf(Gadget8SIBuff,"%-3d",tabspace);
if (sclearmode) Gadget2.Flags |= SELECTED;
else Gadget2.Flags &= ~SELECTED;
if (lacemode) Gadget3.Flags |= SELECTED;
else Gadget3.Flags &= ~SELECTED;
Gadget9.Flags &= ~SELECTED; Gadget10.Flags &= ~SELECTED; Gadget11.Flags &= ~SELECTED;
if (speed==0) Gadget11.Flags |= SELECTED;
if (speed==1) Gadget10.Flags |= SELECTED;
if (speed==2) Gadget9.Flags |= SELECTED;
Gadget12.Flags &= ~SELECTED; Gadget13.Flags &= ~SELECTED; Gadget14.Flags &= ~SELECTED;
if (maxcolor==15) Gadget12.Flags |= SELECTED;
if (maxcolor==7) Gadget13.Flags |= SELECTED;
if (maxcolor==3) Gadget14.Flags |= SELECTED;
if (read_dir) Gadget4.Flags |= SELECTED; else Gadget4.Flags &= ~SELECTED;
strcpy(Gadget1SIBuff,WorkFont.ta_Name);
Gadget1SIBuff[30]='\0';
ConfigWindow=OpenWindow(&NewWindowStructure1);
Crp=ConfigWindow->RPort;
PrintIText(Crp,&IntuiTextList1,0,0);
DrawBorder(Crp,&BorderList1,0,0);
do {
WaitPort(ConfigWindow->UserPort);
while ((message=(struct IntuiMessage *) GetMsg(ConfigWindow->UserPort))!=NULL) {
class = message->Class;
ReplyMsg(message);
if (class==GADGETUP) configexit=congadget(message,ConfigWindow);
}
} while (configexit==0);
CloseWindow(ConfigWindow);
if (configexit==2 || configexit==3) use_changes(maxcolor,lacemode);
if (configexit==3) save_config();
SetWindowSprite();
}
save_config()
{
FILE *fp;
if (!(fp=fopen("prism.cfg","w"))) {
GenErrorReq("Couldn't save CONFIG!");
return();
}
SetPointer(WorkWindow,&BusyPointer,22,16,0,0);
fputs("VER1\n",fp); /* write this out in case of later revision */
fprintf(fp,"%s\n",WorkFont.ta_Name);
fprintf(fp,"%d %d %d %d %d %d",speed,maxcolor,read_dir,lacemode,sclearmode,tabspace);
fclose(fp);
ClearPointer(WorkWindow);
}
congadget(message,win)
struct IntuiMessage *message;
struct Window *win;
{
struct Gadget *igad;
int gadgid;
igad=(struct Gadget *)message->IAddress;
gadgid=igad->GadgetID;
switch (gadgid) {
case 1: return(2);
case 2: return(3);
case 3: return(1);
case 10: GadMXSel(win,&Gadget14,&Gadget12,&Gadget13,&Gadget12);
break;
case 11: GadMXSel(win,&Gadget13,&Gadget12,&Gadget14,&Gadget12);
break;
case 12: GadMXSel(win,&Gadget12,&Gadget13,&Gadget14,&Gadget12);
break;
case 20: GadMXSel(win,&Gadget11,&Gadget9,&Gadget10,&Gadget9);
break;
case 21: GadMXSel(win,&Gadget10,&Gadget9,&Gadget11,&Gadget9);
break;
case 22: GadMXSel(win,&Gadget9,&Gadget10,&Gadget11,&Gadget9);
break;
default: break;
}
return(0);
}
use_changes(omc,olm)
int omc,olm;
{
int maxcol;
tabspace=atoi(Gadget8SIBuff);
if (Gadget2.Flags & SELECTED) sclearmode=1; else sclearmode=0;
if (Gadget3.Flags & SELECTED) lacemode=1; else lacemode=0;
if (Gadget12.Flags & SELECTED) maxcol=15;
if (Gadget13.Flags & SELECTED) maxcol=7;
if (Gadget14.Flags & SELECTED) maxcol=3;
if (Gadget11.Flags & SELECTED) speed=0;
if (Gadget10.Flags & SELECTED) speed=1;
if (Gadget9.Flags & SELECTED) speed=2;
if (Gadget4.Flags & SELECTED) read_dir=1; else read_dir=0;
if (strcmp(Gadget1SIBuff,WorkFont.ta_Name)) {
strcpy(WorkFont.ta_Name,Gadget1SIBuff);
if ((TFont = (struct TextFont *) OpenDiskFont(&WorkFont)) == 0) {
WorkFont.ta_Name = (STRPTR)"topaz.font";
WorkFont.ta_YSize = TOPAZ_EIGHTY;
}
}
Fastest.Flags &= ~CHECKED; TFBaud.Flags &= ~CHECKED; TWBaud.Flags &= ~CHECKED;
if (sclearmode) SClear.Flags |= CHECKED; else SClear.Flags &= ~CHECKED;
switch (speed) {
case 0: Fastest.Flags |= CHECKED;
break;
case 1: TFBaud.Flags |= CHECKED;
break;
case 2: TWBaud.Flags |= CHECKED;
break;
default: break;
}
if (omc != maxcol) {
Forplanes.Flags &= ~CHECKED; Threeplanes.Flags &= ~CHECKED; Twoplanes.Flags &= ~CHECKED;
switch (maxcol) {
case 15: Forplanes.Flags |= CHECKED;
SetupMenu(0,2);
break;
case 7: Threeplanes.Flags |= CHECKED;
SetupMenu(0,1);
break;
case 3: Twoplanes.Flags |= CHECKED;
SetupMenu(0,0);
break;
default: break;
}
}
if (olm != lacemode) {
if (lacemode==0) {
FirstWorkScreen.Height=420;
SetupMenu(2,0);
}
else {
FirstWorkScreen.Height=210;
SetupMenu(2,0);
}
}
maxcolor=maxcol;
}